package com.wangxl.rabbitmqdemo.consumer;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.context.annotation.Configuration;

import java.io.UnsupportedEncodingException;

/**
 * 消息消费者
 * @Author: wangxl
 * @Date: 2019/3/23 13:44
 */
@Configuration
@Slf4j
public class RabbitMQConsumerConfig {

    /**
     * 配置简单的消息消费者
     * @param message
     */
    @RabbitListener(queues = "simpleQueue")
    public void printSimpleMessage(Message message) throws UnsupportedEncodingException {
        byte[] messageBody = message.getBody();
        log.info("simpleQueue receive message---{}",new String(messageBody,"UTF-8"));
    }

}
